package com.fjrz.bbxwj.main.access

import androidx.lifecycle.Observer
import com.module.lemlin.mode.ViewModeFragment
import com.fjrz.bbxwj.R
import com.fjrz.bbxwj.mode.vm.AccessViewModel
import kotlinx.android.synthetic.main.fragment_access_login.*

class LoginFragment : ViewModeFragment<AccessViewModel>() {

    companion object {
        fun newInstance(): LoginFragment {
            return LoginFragment()
        }
    }

    override val layoutResId: Int
        get() = R.layout.fragment_access_login

    override fun viewModel(): AccessViewModel {
        return createViewModel(requireActivity())
    }

    override fun initView() {
        viewModel.observableEditText(etLoginMobileContent)
    }

    override fun initViewMode() {
        viewModel.contentMobileLoginLiveData.observe(viewLifecycleOwner, Observer { mobile ->
            tvLoginGetCode.isEnabled = !(mobile.isNullOrEmpty() || mobile.length != 11)
        })
    }

}